/**
 * 礼品卡相关接口 
 */
var request = require('./request.js');

module.exports = {
  /**
   * 查询本地礼品卡
   */
  queryActivityGroup: function() {
    return request.get('/mbr/giftCard/queryActivityGroup')
  },
  /**
   * 查询礼品卡活动信息详情
   * @param giftCardActivityId 礼品卡活动id
   */
  queryActivityDetails: function(giftCardActivityId) {
    var params = {
      giftCardActivityId: giftCardActivityId
    }
    return request.get('/mbr/giftCard/queryActivityDetails', params)
  },
  /**
   * 查询我的礼品卡
   * @param memberIdEquals 会员id
   * @param stateEquals 礼品卡状态:不传查询所有，UNACTIVATED（未激活），PRESENT（转增中），ACTIVED（已激活），EXPIRED（已过期），ABOLISH（已作废）
   */
  queryMyGiftCard: function(memberId, state) {
    var params = {
      memberIdEquals: memberId,
      stateEquals: state ? state : ''
    }
    return request.get('/mbr/giftCard/queryMyGiftCard', params)
  },
  /**
   * 创建礼品卡订单
   */
  createOrder: function(postData) {
    return request.post('/mbr/giftCard/order/create', postData)
  },
  /**
   * 获取支付签名
   * @param orderId 订单id
   * @param payMethod 支付方式 WX_MINI_APP, SWIFTPASS,WXA_ISV_PAY
   */
  getPaySign: function(postData) {
    return request.post('/mbr/giftCard/order/getPaySign', postData)
  },
  /**
   * 根据礼品卡订单id查询订单状态，支付完成后轮训状态
   * @param orderId 订单id
   */
  getStatusById: function(orderId, payMethod) {
    var params = {
      orderId: orderId
    }
    return request.get('/mbr/giftCard/order/getStatusById', params)
  },

  /**
   * 查询我的礼品卡详情
   * @param cardNo  卡号
   */
  queryMyGiftCardDetails: function(cardNo) {
    var params = {
      cardNo: cardNo
    }
    return request.get('/mbr/giftCard/queryMyGiftCardDetails', params)
  },

  /**
   * 激活礼品卡
   */
  active: function(cardNo) {
    return request.put('/mbr/giftCard/active?cardNo=' + cardNo);
  },

  /**
   * 赠送礼品卡
   * @param cardNo 卡号
   */
  donate: function(cardNo) {
    return request.put('/mbr/giftCard/donate?cardNo=' + cardNo);
  },

  /**
   * 领取赠送的卡
   */
  acquireDonate: function(cardNo) {
    var params = {
      cardNo: cardNo
    }
    return request.get('/mbr/giftCard/acquireDonate', params)
  },

  /**
   * 查询礼品卡信息(不含有使用规则)
   */
  queryGiftCardInfo: function(cardNo) {
    var params = {
      cardNo: cardNo
    }
    return request.get('/mbr/giftCard/queryGiftCardInfo', params)
  },

  /**
   * 获取付款码
   * @param giftCardNo 礼品卡卡号
   */
  getPayCode: function(giftCardNo) {
    var params = {
      giftCardNo: giftCardNo
    }
    return request.get('/mbr/giftCard/getPayCode', params)
  }

}